package com.moqianfan.mcuassistant.net;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2017/6/16.
 */

public class BaseRetorfit {
    private Retrofit retrofit;

    public BaseRetorfit(String base_url) {
        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
        Retrofit.Builder builder = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .baseUrl(base_url);
        retrofit = builder.client(httpClient
                .build()).build();
    }

    public <S> S createService(Class<S> sClass) {
        return retrofit.create(sClass);
    }
}
